# 弧类
# pygame.draw.arc(screen,(0, 119, 184),(120,120,100,300),0,3.14/2,3)
import pygame


class Arc:
    def __init__(self, rect,color,begin, end, wide=3):
        '''
        :param begin: 起始角度
        :param end: 终止角度
        :param wide:
        '''
        self.begin = self.__angle_to_arc(begin)
        self.end = self.__angle_to_arc(end)
        self.wide = wide
        self.rect = rect
        self.color = color

    def draw(self, screen):
        self.rect = pygame.draw.arc(screen
                        , self.color
                        , self.rect
                        , self.begin
                        , self.end
                        , self.wide
                        )
        return self.rect

    def get_rect(self):
        return self.rect

    # 角度to弧度
    def __angle_to_arc(self, angle):
        import math
        arc = angle % 360 * math.pi / 180
        return arc


if __name__ == '__main__':
    pygame.init()
    screen = pygame.display.set_mode((200, 200))
    fps = pygame.time.Clock()
    # 绘制arc时作为参数传入的rect
    rect = pygame.Rect(50,50,60,60)
    pygame.draw.rect(screen,(255,255,255),rect,1)
    arc = Arc(rect,(100,100,100),45,360)
    # 画完arc后arc占据的rect
    arc_rect = arc.draw(screen)
    pygame.draw.rect(screen,(29, 214, 108),arc_rect,1)

    while True:
        # screen.fill((0, 0, 0))
        pygame.display.update()
        fps.tick(10)
